import React, { Component } from 'react'
import { Table, Tag, Space, Button } from 'antd';
import { cfyList } from '../../api/goods';

const columns = [
  {
    title: 'ObjectId',
    dataIndex: 'objectId',
    key: 'objectId',
    render: text => <a>{text}</a>,
  },
  {
    title: '分类名称',
    dataIndex: 'bname',
    key: 'bname',
  },
  {
    title: '类别bid',
    dataIndex: 'bid',
    key: 'bid',
  },
  {
    title: '商品总数',
    dataIndex: 'num',
    key: 'num',
  },
  {
    title: '操作',
    key: 'action',
    render: (text, record) => (
      <Space size="middle">
        <Button type='primary' size='small'>编辑</Button>
        <Button type='primary' size='small' danger>删除</Button>
      </Space>
    ),
  },
];

// const data = [ //默认测试数据包
//   {
//     objectId:'asdfasdf',
//     bname:'所有蛋糕',
//     bid:11,
//     num:30
//   }
// ];
export default class CfyList extends Component {
  constructor(){
    super()
    this.state = {
      list:[]
    }
  }
  componentDidMount(){
    cfyList().then(res=>{
      console.log(res);
      this.setState({
        list:res.data.results
      })
    })
  }
  render() {
    return (
      <Table 
        columns={columns} 
        dataSource={this.state.list} 
        rowKey="objectId"
        pagination={{
          pageSize:2
        }}
      />
    )
  }
}



